import request from '@/api/request'
import { downloadFile, uploadFile, getApiUrl } from '@/api/download'
import g from "@/utils/utilFn";
export function getlist(param) {
    param = g.objEngraving({
        start: '',
        end: '',
        phone_num: "",
        belong_to: "",
        tel_traffic: "",
        tel_type: "",
        page: 1,
        limit: 10,
        filed: 'id',
        sort: 'ascending'
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_cart/getlist',
        method: 'POST',
        data
    })
}
export function getOneByNum(phone_num) {
    let data = new FormData()
    data.append("phone_num", phone_num || "");
    return request({
        url: '/adm_cart/getOneByNum',
        method: 'POST',
        data
    })
}
export function remove_by_id(id) {
    let data = new FormData()
    data.append("id", id || "");
    return request({
        url: '/adm_cart/delete_by_id',
        method: 'POST',
        data
    })
}
export function notExistAdd(param) {
    param = g.objEngraving({
        phone_num: "",
        belong_to: "",
        tel_package: "",
        tel_traffic: "",
        tel_type: "",
        discount_exp_date: "",
        wechat_pwd: "",
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_cart/notExistAdd',
        method: 'POST',
        data
    })
}

export function update(param) {
    param = g.objEngraving({
        id: "",
        phone_num: "",
        belong_to: "",
        tel_package: "",
        tel_traffic: "",
        tel_type: "",
        discount_exp_date: "",
        wechat_pwd: "",
    }, param || {})
    let data = new FormData()
    Object.keys(param).map((key) => {
        data.append(key, param[key] || "");
    });
    return request({
        url: '/adm_cart/update',
        method: 'POST',
        data
    })
}


export function down_model() {
    var fileName = "model_582c4102-34eb-11ef-a12f-00163e0acd8d.xls"
    downloadFile(fileName, "电话卡模板.xls")
}
export const up_load_url = getApiUrl('/file/up_file/cart_model.xls')

export function batch_processing(random) {
    let data = new FormData()
    data.append("random", random);
    return request({
        url: '/adm_cart/batch_processing/cart_model.xls',
        method: 'POST',
        data
    })
}


export const typeArray = [
    { id: 1, name: '主卡' },
    { id: 2, name: '副卡' },
    { id: 3, name: '无' }
]